package com.example.dllo.exe.giftspeak;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.dllo.exe.R;
import com.example.dllo.exe.bean.SouSuoGongLueDanPinBean;

/**
 * code is far away from bug with the animal protecting
 * <p>
 * ┏┓　　　┏┓
 * ┏┛┻━━━┛┻┓
 * ┃　　　　　　　┃
 * ┃　　　━　　　┃
 * ┃　┳┛　┗┳　┃
 * ┃　　　　　　　┃
 * ┃　　　┻　　　┃
 * ┃　　　　　　　┃
 * ┗━┓　　　┏━┛
 * 　　┃　　　┃神兽保佑
 * 　　┃　　　┃永无BUG！  凯哥 祝你一路顺风
 * 　　┃　　　┗━━━┓
 * 　　┃　　　　　　　┣┓
 * 　　┃　　　　　　　┏┛
 * 　　┗┓┓┏━┳┓┏┛
 * 　　　┃┫┫　┃┫┫
 * 　　　┗┻┛　┗┻┛
 */
public class GiftSouSuoRvAdapter extends RecyclerView.Adapter<GiftSouSuoRvAdapter.MyViewHolder> {
    private Context context;
    private SouSuoGongLueDanPinBean suoGongLueDanPinBean;

    public GiftSouSuoRvAdapter(Context context) {
        this.context = context;
    }

    public void setSuoGongLueDanPinBean(SouSuoGongLueDanPinBean suoGongLueDanPinBean) {
        this.suoGongLueDanPinBean = suoGongLueDanPinBean;
        notifyDataSetChanged();
    }

    @Override
    public GiftSouSuoRvAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.sousuogongluedanpinlayout, parent, false);
        MyViewHolder viewHolder = new MyViewHolder(view);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(GiftSouSuoRvAdapter.MyViewHolder holder, int position) {
        holder.gongluedanpintext.setText(suoGongLueDanPinBean.getData().getHot_words().get(position));

        Log.d("GiftSouSuoRvAdapter", suoGongLueDanPinBean.getData().getHot_words().get(position));
    }

    @Override
    public int getItemCount() {
        return suoGongLueDanPinBean != null ? suoGongLueDanPinBean.getData().getHot_words().size() : 0;

    }


    public class MyViewHolder extends RecyclerView.ViewHolder {
        TextView gongluedanpintext;

        public MyViewHolder(View itemView) {
            super(itemView);
            gongluedanpintext = (TextView) itemView.findViewById(R.id.text_sousuogongluedanpin);
        }
    }
}
